﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            // 定义一个一维数组，数组中存放一些数据（控制台输入）。
            //定义几个变量：max、min、sum、avg
            //定义一个方法，方法返回数组元素之和,方法形参有max min avg

            int[] arr = new int[2];
            
            int sum = 0;
            int avg = 0;

            for (int i = 0; i < arr.Length; i++)
            {
                Console.WriteLine("请输入");
                arr[i] = int.Parse(Console.ReadLine());
            }
            int max = arr[0];
            int min = arr[0];

              sum = Text(ref max, ref min, ref avg, arr);
              sum = Text1(out max, out min, out avg,  arr);
             Console.WriteLine("最大值是{0}，最小值是{1}，平均值是{2}，和是{3}",max,min,avg,sum);
        }
        public static int Text(ref int max, ref int min, ref int avg, int[] arr)
        {
            int sum = 0;

            for (int i = 0; i < arr.Length; i++)
            {
                if (max < arr[i])
                {
                    max = arr[i];
                }
                if (min > arr[i])
                {
                    min = arr[i];
                }

                sum = sum + arr[i];
            }
          

            avg = sum / 4;

            return sum;
        }
        public static int Text1(out int max, out int min, out int avg, int[] arr)
        {
             int sum = 0;
                 avg = 0;
             max = arr[0];
             min = arr[0];

            for (int i = 0; i < arr.Length; i++)
            {
                if (max < arr[i])
                {
                    max = arr[i];
                }
                if (min > arr[i])
                {
                    min = arr[i];
                }

                sum = sum + arr[i];
            }


            avg = sum / 2;

            return sum;
        }




    }
}


